<template>
	<view class="cu-bar tabbar bg-white shadow foot">
		<view class="action" @click="navTo(0)">
			<view class="cuIcon-cu-image"><image :src="`/static/tabbar/index${tabIndex == '0' ? '_selected' : '_default'}@2x.png`"></image></view>
			<view :class="[tabIndex == '0' ? 'default-theme-color' : '']">首页</view>
		</view>
		<view class="action" @click="navTo(2)">
			<view class="cuIcon-cu-image"><image :src="`/static/tabbar/order_${tabIndex == '2' ? 'selected' : 'default'}.png`"></image></view>
			<view :class="[tabIndex == '2' ? 'default-theme-color' : '']">订单</view>
		</view>
	</view>
</template>

<script>
import { mapState } from 'vuex';
export default {
	data() {
		return {};
	},
	props: {
		tabIndex: {
			type: [Number, String],
			default: 0
		}
	},
	computed: {
		...mapState(['cartNum'])
	},
	methods: {
		navTo(index) {
			if (index == this.tabIndex) {
				return;
			}
			this.$emit('tabChange', index);
		}
	}
};
</script>

<style scoped>
.bg-white {
	background: #fff;
}
.cu-bar.fixed,
.nav.fixed {
	position: fixed;
	width: 100%;
	top: 0;
	z-index: 1024;
	box-shadow: 0 1upx 6upx rgba(0, 0, 0, 0.1);
}

.cu-bar {
	display: flex;
	position: relative;
	align-items: center;
	min-height: 100rpx;
	justify-content: space-between;
}
.cu-bar .action {
	display: flex;
	align-items: center;
	height: 100%;
	justify-content: center;
	max-width: 100%;
}
.cu-bar.foot {
	position: fixed;
	width: 100%;
	bottom: 0;
	z-index: 1024;
	box-shadow: 0 -1upx 6upx rgba(0, 0, 0, 0.1);
}

.cu-bar.tabbar {
	padding: 0;
	height: calc(100upx + env(safe-area-inset-bottom) / 2);
	padding-bottom: calc(env(safe-area-inset-bottom) / 2);
}

.cu-tabbar-height {
	min-height: 100upx;
	height: calc(100upx + env(safe-area-inset-bottom) / 2);
}

.cu-bar.tabbar.shadow {
	box-shadow: 0 -1upx 6upx rgba(0, 0, 0, 0.1);
}

.cu-bar.tabbar .action {
	font-size: 22upx;
	position: relative;
	flex: 1;
	text-align: center;
	padding: 0;
	display: block;
	height: auto;
	line-height: 1;
	margin: 0;
	background-color: inherit;
	overflow: initial;
}
.cu-bar.tabbar .action [class*="cuIcon-"] {
	width: 100rpx;
	position: relative;
	display: block;
	height: auto;
	margin: 0 auto 10rpx;
	text-align: center;
	font-size: 40rpx;
}
.cu-bar.tabbar .action .cuIcon-cu-image {
	margin: 0 auto;
}
.cu-bar.tabbar .action .cuIcon-cu-image image {
	width: 50rpx;
	height: 50rpx;
	display: inline-block;
}
.tabbar {
	color: #b7b7b7;
}
.default-theme-color {
	color: #fe4d0e;
}
</style>
